package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.demo.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {

    //select id,username,password,age FROM user_info WHERE username = "admin"
    @Select("select id,username,password,age FROM user_info ${ew.customSqlSegment}")
    List<UserInfo> selectByCustom(@Param(Constants.WRAPPER) Wrapper wrapper);

    List<UserInfo> selectByCustom2(@Param(Constants.WRAPPER) Wrapper wrapper);

    //UPDATE user_info SET delete_flag=0, age=5 WHERE id IN (1,2,3)
    @Update("UPDATE user_info SET age = age + #{age}} ${ew.customSqlSegment}")
    List<UserInfo> update(@Param("age") Integer age, @Param(Constants.WRAPPER) Wrapper wrapper);
}
